import { useReducer } from "react";

const useReducerState = (initialState = []) => {
  const reducer = (state, action) => {
    const { value, index } = action;
    const values = [...state];
    values[index] = value;
    return values;
  };

  return useReducer(reducer, initialState);
};

export default useReducerState;
